package com.wing.order.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.order.dao.InventoryAlarmDetailDao;
import com.wing.order.model.entity.InventoryAlarmDetail;
import com.wing.order.model.request.InventoryAlarmDetailForm;
import com.wing.order.model.response.InventoryAlarmDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 告警明细-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class InventoryAlarmDetailServiceImpl extends ServiceImpl<InventoryAlarmDetailDao, InventoryAlarmDetail> implements InventoryAlarmDetailService {

    @Override
    public int add(InventoryAlarmDetailForm inventoryAlarmDetailForm) {

        //校验

        InventoryAlarmDetail inventoryAlarmDetail =new InventoryAlarmDetail();
        CopyOptions copyOptions = CopyOptions.create()
        .setEditable(InventoryAlarmDetail.class)
        .setIgnoreError(true)
        .setIgnoreNullValue(true);
        BeanUtil.copyProperties(inventoryAlarmDetailForm, inventoryAlarmDetail, copyOptions);

        return baseMapper.insert(inventoryAlarmDetail);
    }

    @Override
    public List<InventoryAlarmDetailVO> list4app(Map<String, Object> params) {
        return baseMapper.list4app(params);
    }

    @Override
    public Page<InventoryAlarmDetailVO> pageList4app(Page page, Map<String, Object> params) {
        List<InventoryAlarmDetailVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public InventoryAlarmDetailVO get4appById(Long id) {
        return baseMapper.get4appById(id);
    }
}
